package little.bunny;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.widget.Toast;

public class NetFunction {
	public static Boolean CheckNetStatus(Context ctx)
	{
		ConnectivityManager connManager = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo info = connManager.getActiveNetworkInfo();

		if (info != null && info.isAvailable()) {
			NetworkInfo.State state = connManager.getNetworkInfo(
					ConnectivityManager.TYPE_MOBILE).getState();
			if (state == NetworkInfo.State.CONNECTED) {
				// //Log.i("通知", "GPRS网络已连接");
				// Toast.makeText(this, "GPRS网络已连接", Toast.LENGTH_SHORT).show();
			}
			
			state = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
					.getState();
			if (state == NetworkInfo.State.CONNECTED) {
				// //Log.i("通知", "WIFI网络已连接");
				// Toast.makeText(this, "WIFI网络已连接", Toast.LENGTH_SHORT).show();
			}
			// // 跳转到无线网络设置界面
			// startActivity(new
			// Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
			// // 跳转到无线wifi网络设置界面
			// startActivity(new
			// Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));

			return true;
		} else {
			Toast.makeText(ctx, "没有联网 ", Toast.LENGTH_SHORT).show();
			return false;
		}
	}
}
